<?php
	@session_start();
	@require_once '../script/common.php';
	if( !is_object($db) ){
		@require_once DOCUMENT_ROOT.'/script/db.class.php';
		$db = new db();
	}
//function getsStatus($code,$cursor){//$cursor最多支持16位
//	$result = 0;
//	if($cursor < 16){
//		$seed = 1;
//		while($cursor > 1){
//			$seed *= 2;
//			$cursor--;
//		}
//		$temp = $code&$seed;
//		if($temp != 0){
//			$result = 1;
//		}
//	}
//	return $result;
//}
?>
<div id="leftcon" style="" class="conLeft">
<script type="text/javascript">
function changeMenu(index,id){
	var left_id='l'+id;
	if(document.getElementById(left_id).style.display == 'none' ){
		document.getElementById(left_id).style.display='';
	}else{
		document.getElementById(left_id).style.display='none';
	}
	//*
	$.ajax({
		type: "post",
		url : "script/api.php",
		dataType:'json',
		data:'action=changeS&cursor='+index,
		success: function(json){
			//alert(json.result);
		}
	});
	//*/
}
</script>
<a href="index.php"><img src="images/zljlw_22.jpg" width="196" height="50" alt="" border="0" /></a>
<?php
	$sql_left = "SELECT A.ID AS ID, (SELECT B.NAME FROM meinian_admin_permission AS B WHERE B.ID = A.PARENT) AS NAME,A.PARENT AS PARENT FROM meinian_admin_permission AS A WHERE  A.PARENT > '0' AND A.ID IN (SELECT C.PERMISSION_ID AS ID FROM meinian_admin_role_permission AS C ,meinian_admin_user_role AS D WHERE D.USER_ID ='".$_SESSION['ADMIN']."' AND D.ROLE_ID = C.ROLE_ID ) ORDER BY A.PARENT ";
//	echo $sql_left;
	$id_left = 0;
	$result_left = $db->doSql($sql_left);
	//print_r($result_left);
	$cursor = 1;
	for($i= 0 ; isset($result_left[$i]) ; ){
		$id_left = $result_left[$i]['PARENT'];
?>
		<div class="yhgl">
		<h2 id="e<?php echo $i;?>" style="cursor:pointer;" onclick="changeMenu(<?php echo $cursor;?>,this.id);"><?php echo $result_left[$i]['NAME'];?></h2>
		<ul id="le<?php echo $i; /*echo "*".$cursor."=>".getStatus($_SESSION['MENU'],$cursor);*/?>" style="<?php if(!getsStatus($_SESSION['MENU'],$cursor)){echo "display:none;";}?>" >
		<?php
		while($result_left[$i]['PARENT'] == $id_left){
			$sql_left = "SELECT NAME,URL FROM meinian_admin_permission WHERE ID='".$result_left[$i]['ID']." ' ";
			foreach($db->doSql($sql_left) as $arr_left ) ;
		?>
			<li><a href="<?php echo WEBSITE_URL.$arr_left['URL'];?>"><?php echo $arr_left['NAME'];?></a></li>
		<?php
			$i++;
		}
		?>
		</ul>
		</div>
<?php
	$cursor++;
	}
?>
</div>